//
//  chatViewcontroller.m
//  Final
//
//  Created by lanou3g on 15/12/4.
//  Copyright © 2015年 皮比诺. All rights reserved.
//

#import "chatViewcontroller.h"
//#import "chathandle.h"
#import "chattingViewController.h"
#import <AVOSCloudIM.h>
#import "FriendTableViewController.h"
@interface chatViewcontroller ()
@property (weak, nonatomic) IBOutlet UITextField *nameTextfield;

@property (weak, nonatomic) IBOutlet UITextField *passWordfield;

@end

@implementation chatViewcontroller
- (IBAction)login:(id)sender {
    
        if ([self.nameTextfield.text length] != 0) {
            AVIMClient *imclient = [AVIMClient defaultClient];
            NSString *selfClientId = self.nameTextfield.text;

        [imclient openWithClientId:selfClientId callback:^(BOOL succeeded, NSError *error) {
            
            if (error) {
                NSLog(@"登陆出现错误");
            }else{
                
                NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
                [defaults setObject:selfClientId forKey:@"clientId"];
                [defaults synchronize];
                
                NSLog(@"登陆成功");
                FriendTableViewController *frientVc = [[FriendTableViewController alloc]init];
                
                [self.navigationController pushViewController:frientVc animated:YES];
                
                
            }
            
        }];
        
        
        }else{
            
            NSLog(@"请输入用户名");
        }
 
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
      self.view.backgroundColor = [UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1];
    

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}





































//- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
//{
//    
////    chathandle *chat = [chathandle sharehanle];
////   [chat sendMessaWithClientId:nil toFriends:nil withText:nil name:nil];
//
////    [chat queryConversationBymebers:nil];
//    
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dosomething:) name:@"123" object:nil];
//    
//    chathandle *handle = [chathandle sharehanle];
//    [handle queryConversationBymebers:nil];
//    
//
//
//-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
//{
//        chattingViewController *chattingVc = [[UIStoryboard storyboardWithName:@"Main" bundle:nil]instantiateViewControllerWithIdentifier:@"chattingVc"];
//    
//        [self presentViewController:chattingVc animated:YES completion:^{
//    
//        }];
//    
//    
//}
//







//    
//    
//}
//
//- (void)dosomething:(id)sender
//{
//    NSLog(@"%@", sender);
//}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
